package com.ruoyi.web.controller.delivery;

import com.alibaba.fastjson.JSONObject;
import com.jianqiao.delivery.jnttrack.entity.JntCancelEntity;
import com.jianqiao.delivery.jnttrack.entity.JntCreateEntity;
import com.jianqiao.delivery.jnttrack.entity.TariffCheckEntity;
import com.jianqiao.delivery.jnttrack.entity.vo.JntTrackResponseVo;
import com.jianqiao.delivery.jnttrack.service.JntTrackService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * author: cyx
 * create: 2024/8/12 18:14
 **/
@RestController
@RequestMapping("/jnt")
public class JntTrackController {

    @Autowired
    private JntTrackService jntTrackService;

    @PostMapping("/track")
    public AjaxResult jnttrack(@RequestBody Map<String ,String> paramMap){
        String awbNumber = paramMap.get("awbNumber");
        List<JntTrackResponseVo> trackResponse = jntTrackService.jnttrack(awbNumber);
        return AjaxResult.success(trackResponse);
    }

    @PostMapping("/create")
    public AjaxResult create(@RequestBody JntCreateEntity jntCreateEntity){
        String response = jntTrackService.create(jntCreateEntity);
        return AjaxResult.success(response);
    }

    @PostMapping("/cancel")
    public AjaxResult cancel(@RequestBody JntCancelEntity jntCancelEntity) {
        String response = jntTrackService.cancel(jntCancelEntity);
        return AjaxResult.success(response);
    }

    @PostMapping("/tariffCheck")
    public AjaxResult tariffCheck(@RequestBody TariffCheckEntity tariffCheckEntity) {
        String response = jntTrackService.tariffCheck(tariffCheckEntity);
        return AjaxResult.success(response);
    }
}
